import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
	
	state: {
		
		URL: "http://weikajie.zanboon.com/",
		
		//#ifdef H5
			
		//#endif
		// #ifdef MP-WEIXIN
			// URL: "https://hkb.zanboon.com",
			// const key="FROBZ-HAA35-37SI6-QXLMI-DQNAF-W3BUG";
			// const referer="订票宝";
			// wx.navigateTo({
			// 	url:'plugin://chooseLocation/index?key'+ key + referer
			// });
		//#endif
		token: '',//q0REc3IkZ7QCxjgsvuBV
		list:['123'],
		store_id: 0,
		nickName: '', //昵称
		avatarUrl: '', //头像
		bindingCard: '', //绑定银行卡i
		organID: '', //机构id
		customer_id: '', //用户id
		bankOfDepositId: '', //开户主行id
		bankOfDeposit: '', //开户主行名称
		subBranch: '', //主行支行名称
		subBranchId: '', //主行支行id
		orderid: '', //订单id
		orderTime: '', //下单时间
		actForm: null,
		joinActShopID: [], //创建活动参与门店id
		joinActShopName: [], //创建活动参与门店名称
		joinActShopAddre: [],
		store_url:'https://hkbh5.zanboon.com',
		share: 0, // 是否通过分享进入
		imgLink:'https://tool.tuanhaoke.cn/static/image/',
		// qqmapkey:'BFLBZ-ZG6C5-R3FIB-Q3IMS-BEZA2-7OFS6', //订票宝腾讯地图appId绑定key
		qqmapkey : 'FROBZ-HAA35-37SI6-QXLMI-DQNAF-W3BUG', //课拍拍腾讯地图appId绑定key
	},
	getters: {
		getUrl(state) {
			return state.URL;
		},
		getToken(state) {
			if (state.token) {
				return state.token
			} else {
				return uni.getStorageSync('token');
			}
		},
		setToken() {
			return uni.setStorageSync('token', )
		},
		getIndentId(state) {
			if (state.bindingCard != '') {
				return state.bindingCard;
			} else {
				return uni.getStorageSync('bindingCard');
			}
		},
		getCustomerId(state) {
			if (state.customer_id != '') {
				return state.customer_id;
			} else {
				return uni.getStorageSync('customer_id');
			}
		},
		getOrganId(state) {
			if (state.organID != '') {
				return state.organID
			} else {
				return uni.getStorageSync('OrganId');
			}
		},
		getStoreId(state) {
			if (state.store_id != '') {
				return state.store_id
			} else {
				return uni.getStorageSync('store_id');
			}
		},
	},
	mutations: {
		updateToken(state, token) {
			uni.setStorage({
				key: 'token',
				data: token,
				success: function() {}
			});
			state.token = token;
		},
		updataShare(state, share) {
			state.share = share
		},
		updateStoreId(state, store_id) {
			state.store_id = store_id
		},
		updataIndentId(state, bindingCard) {
			state.bindingCard = bindingCard
		},
		updataCustomerId(state, customer_id) {
			state.customer_id = customer_id
		},
		updataOrganId(state, organID) {
			state.organID = organID
		},
		updataUserInfo(state, info) {
			if (info.account_id) {
				state.account_id = account_id
			}
			uni.setStorage({
				key: 'nickName',
				data: info.nickname,
				success: function() {}
			});
			uni.setStorage({
				key: 'avatarUrl',
				data: info.headimgurl,
				success: function() {}
			});
			state.nickName = info.nickname;
			state.avatarUrl = info.headimgurl;
		},
	},
	actions:{
		getList(context){
			axios.get('http://192.168.1.80:3344/goods/good/get_list?toke=os2rftxaXgM0vWL1QzOH').then(({res})=>{
				console.log(res)
			})
		}
	}
})
export default store